<%--
  Created by IntelliJ IDEA.
  User: taohj
  Date: 2014/6/29
  Time: 18:04
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://"
            + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
%>
<c:set var="dashboardMenuTag" value="mydataset" scope="request"></c:set>
<c:set var="menu" value="none" scope="request"></c:set>

<!Doctype html>
<html>
<head>
    <base href="<%=basePath%>">
    <title>政府数据开放平台</title>
    <jsp:include page="../../commons/include.jsp"/>
    <script>
        $(function () {
            $(".pagination li").on('click', function () {
                $('form input[name="page"]').val($(this).attr("page"));
                $("form").submit();
            });

            $(".table tbody tr").each(function (index) {

                var dataset = $(this).attr('dataset');

                $(this).find(":last-child :first-child  li:first").on('click', function () {
                    location.href = '/front/my/dataset/modifyV?id=' + dataset;
                });

                $(this).find(":last-child :first-child li:last").on('click', function () {
                    if (confirm("确定要删除吗？")) {
                        var appid = $(this).attr('appid');
                        location.href = '/front/my/dataset/remove?id=' + dataset;
                    }
                });
            });

            $("form select").on('change', function () {
                $("form").submit();
            });

        });
    </script>



</head>
<body>

<jsp:include page="../../commons/top.jsp"/>
<div class="main">

    <div>
        <jsp:include page="../../commons/dashboardMenu.jsp"/>
    </div>




    <div class="left">
        <ul>
            <li href="/front/my/dataset/list" class="active">数据集管理</li>
            <li href="/front/my/dataset/data/list">数据管理</li>
        </ul>
    </div>

    <div class="right">




        <div style=" min-height: 80px">

            <div style="height: 40px; width: 100%;padding: 20px 0px 20px 20px;">
                <input type="button"
                       onclick="location.href='/front/my/dataset/createV'"
                       value="新增">
            </div>


            <div>
                <form action="/front/my/dataset/list" style="padding-left: 30px">
                    <input type="hidden" name="page">
                    <table style="width: 840px;">
                        <tr>
                            <td style="width: 40px;">名称：</td>
                            <td><input type="text" name="name" style="min-width: 100px" value="${requestScope.result.pageResult.t.name}"></td>
                            <td width="8"></td>
                            <td style="width: 40px;">主题：</td>
                            <td>
                                <select name="theme" dataSync='true' syncType='datatheme'  selectValue="${requestScope.result.pageResult.t.theme.id}"  style="min-width: 100px">
                                    <option value="">请选择</option>
                                </select>
                            </td>
                            <td width="10"></td>
                            <td style="width: 40px;">排序：</td>
                            <td><select name="order" style="min-width: 100px;font-size: 14px;height: 28px;">
                                <option value="asc">名称升序</option>
                                <option value="desc"
                                        <c:if test="${requestScope.result.pageResult.sortBy=='desc'}">selected="selected" </c:if> >
                                    名称降序
                                </option>
                            </select></td>
                            <td width="20"></td>

                            <td><input type="submit" value="搜索"></td>
                        </tr>
                    </table>

                </form>

            </div>

        </div>


        <div style="padding: 20px 20px">
            <span style="font-size: 16px;font-weight: bold;">共找到条${requestScope.result.pageResult.total}记录</span>
        </div>


        <div style="padding-left: 16px;min-height: 320px">
            <table width="100%" class="table">

                <thead>
                <tr>
                    <td width="60">序号</td>
                    <td width="100">名称</td>
                    <%--<td width="100">机构</td>--%>
                    <td width="100">主题</td>
                    <td width="40">状态</td>
                    <td width="100">创建时间</td>
                    <td width="10">操作</td>
                </tr>
                </thead>


                <tbody>
                <c:choose>
                    <c:when test="${not empty requestScope.result.pageResult.rows}">
                        <c:forEach items="${requestScope.result.pageResult.rows}" var="dataset" varStatus="status">
                            <tr dataset="${dataset.id}">
                                <td>${status.count+requestScope.result.pageResult.page*requestScope.result.pageResult.size-requestScope.result.pageResult.size}</td>
                                <td>
                                    <a href="/front/my/dataset/data/list?dataset=${dataset.id}">${dataset.name}</a>
                                </td>
                                    <%-- <td>${dataset.org.name}</td>--%>
                                <td>${dataset.theme.name}</td>
                                <td>${dataset.status.name}</td>
                                <td>

                                    <jsp:useBean id="now" class="java.util.Date"></jsp:useBean>
                                    <fmt:formatDate value="${dataset.createTime}" pattern="yyyy-MM-dd HH:mm:ss"/>
                                        <%--${dataset.createTime}--%>
                                        <%-- <%-- <c:if test="${not empty dataset.createTime}">

                                          </c:if>--%>
                                </td>

                                <td>
                                    <ul id="icons" class="ui-widget ui-helper-clearfix">
                                        <li class="ui-state-default ui-corner-all" title="更新"><span class="ui-icon ui-icon-pencil"></span></li>
                                        <li class="ui-state-default ui-corner-all" title="删除"><span class="ui-icon ui-icon-trash"></span></li>
                                    </ul>
                                </td>
                            </tr>
                        </c:forEach>
                    </c:when>
                    <c:otherwise>
                        <tr>
                            <td colspan="8" style="padding: 16px;font-size: 14px; font-family: '宋体'">无数据</td>
                        </tr>
                    </c:otherwise>
                </c:choose>
                </tbody>
            </table>
        </div>


        <div>
            <ul class="pagination" style="margin: 20px 30px;">
                <li page="${requestScope.result.pageResult.startPage-1}">&laquo;</li>

                <c:forEach begin="${requestScope.result.pageResult.startPage}"
                           end="${requestScope.result.pageResult.endPage}" var="index">
                    <li page="${index}" <c:if
                            test="${index==requestScope.result.pageResult.page}"> class="active" </c:if> >${index}
                    </li>
                </c:forEach>

                <li page="${requestScope.result.pageResult.endPage+1}">&raquo;</li>
            </ul>
        </div>
    </div>

</div>


<jsp:include page="../../commons/buttom.jsp"/>
</body>
</html>
